﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class Person
    {
        public string ID { get; set; }
        public string PersonID { get; set; }
        public string EditorUserID { get; set; }
        public string EditorUserName { get; set; }
        public string NationalNumber { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string FatherName { get; set; }
        public string IdentityNumber { get; set; }
        public string Birthday { get; set; }
        public string Job { get; set; }
        public string Telephone1 { get; set; }
        public string Telephone2 { get; set; }
        public string HomeAddress { get; set; }
        public string Image { get; set; }
        public string Description { get; set; }
        public string Timestamp { get; set; }
        public string BackColor { get; set; }

        public Person(DataAccessLayer.Person Person)
        {
            this.ID = Person.ID.ToString();
            this.PersonID = Person.PersonID.ToString();
            this.EditorUserID = Person.EditorUserID.ToString();
            this.EditorUserName = Person.sUser.Users.Last().Username;
            this.NationalNumber = Person.NationalNumber;
            this.FirstName = Person.FirstName;
            this.LastName = Person.LastName;
            this.FatherName = Person.FatherName;
            this.IdentityNumber = Person.IdentityNumber;
            this.Birthday = Person.Birthday;
            this.Job = Person.Job;
            this.Telephone1 = Person.Telephone1;
            this.Telephone2 = Person.Telephone2;
            this.HomeAddress = Person.HomeAddress;
            //this.Image = Person.Image;
            this.Image = "بدون تصویر";
            this.Description = Person.Description;
            this.Timestamp = Person.Timestamp.ToHijriSolarString();
            this.BackColor = Person.IsDeleted ? "#FF5555" : "#FFFFFF";
        }

        public static List<Person> Convert(List<DataAccessLayer.Person> Persons)
        {
            return (Persons.ConvertAll(new Converter<DataAccessLayer.Person, Person>(p => (new Person(p)))));
        }
    }
}
